package com.yida.gwj.report.service.impl;

import com.yida.common.core.utils.DateUtils;
import com.yida.gwj.report.domain.GwjSysCalculateRate;
import com.yida.gwj.report.mapper.GwjSysCalculateRateMapper;
import com.yida.gwj.report.service.IGwjSysCalculateRateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

/**
 * 系统结息Service业务层处理
 *
 * @author lqq
 * @date 2024-02-28
 */
@Service
public class GwjSysCalculateRateServiceImpl implements IGwjSysCalculateRateService {
    @Resource
    private GwjSysCalculateRateMapper gwjSysCalculateRateMapper;

    /**
     * 查询系统结息
     *
     * @param id 系统结息主键
     * @return 系统结息
     */
    @Override
    public GwjSysCalculateRate selectGwjSysCalculateRateById(Long id) {
        return gwjSysCalculateRateMapper.selectGwjSysCalculateRateById(id);
    }

    /**
     * 查询系统结息列表
     *
     * @param gwjSysCalculateRate 系统结息
     * @return 系统结息
     */
    @Override
    public List<GwjSysCalculateRate> selectGwjSysCalculateRateList(GwjSysCalculateRate gwjSysCalculateRate) {
        return gwjSysCalculateRateMapper.selectGwjSysCalculateRateList(gwjSysCalculateRate);
    }

    /**
     * 根据结算时间查询之前系统结息列表
     *
     * @param localDate 结算时间
     * @return 系统结息集合
     */
    @Override
    public List<GwjSysCalculateRate> selectGwjSysCalculateRateListBeforeDate(LocalDate localDate){
        return gwjSysCalculateRateMapper.selectGwjSysCalculateRateListBeforeDate(localDate);
    }

    /**
     * 查询系统结息
     *
     * @param gwjSysCalculateRate 系统结息
     * @return 系统结息
     */
    @Override
    public GwjSysCalculateRate selectGwjSysCalculateRate(GwjSysCalculateRate gwjSysCalculateRate) {
        return gwjSysCalculateRateMapper.selectGwjSysCalculateRate(gwjSysCalculateRate);
    }

    /**
     * 新增系统结息
     *
     * @param gwjSysCalculateRate 系统结息
     * @return 结果
     */
    @Override
    public int insertGwjSysCalculateRate(GwjSysCalculateRate gwjSysCalculateRate) {
        gwjSysCalculateRate.setCreateTime(DateUtils.getNowDate());
        return gwjSysCalculateRateMapper.insertGwjSysCalculateRate(gwjSysCalculateRate);
    }

    /**
     * 修改系统结息
     *
     * @param gwjSysCalculateRate 系统结息
     * @return 结果
     */
    @Override
    public int updateGwjSysCalculateRate(GwjSysCalculateRate gwjSysCalculateRate) {
        return gwjSysCalculateRateMapper.updateGwjSysCalculateRate(gwjSysCalculateRate);
    }

    /**
     * 批量删除系统结息
     *
     * @param ids 需要删除的系统结息主键
     * @return 结果
     */
    @Override
    public int deleteGwjSysCalculateRateByIds(Long[] ids) {
        return gwjSysCalculateRateMapper.deleteGwjSysCalculateRateByIds(ids);
    }

    /**
     * 删除系统结息信息
     *
     * @param id 系统结息主键
     * @return 结果
     */
    @Override
    public int deleteGwjSysCalculateRateById(Long id) {
        return gwjSysCalculateRateMapper.deleteGwjSysCalculateRateById(id);
    }

    /**
     * 查询上一个结息
     *
     * @param areaId        地区ID
     * @param calculateTime 结算时间
     * @return 结果
     */
    @Override
    public GwjSysCalculateRate selectLastCalculateRate(Long areaId, LocalDate calculateTime) {
        return gwjSysCalculateRateMapper.selectLastCalculateRate(areaId, calculateTime);
    }
}
